#pragma once

#include <struct/query_context.hpp>
#include <struct/context_operations.hpp>
#include <data/sql/sql_expr.hpp>
#include <serialization/writer_options.hpp>
#include <data/data_result.hpp>

namespace blitz_query_cpp
{
    class process_errors
    {
    public:
        bool process(query_context &context)
        {
            data_result_t & root_node = get_data_result(context);
            if(context.error_msgs.size())
            {
                value_node_t &errors = root_node.add_child_node(value_kind::List, "errors");
                for (auto &&error_msg : context.error_msgs)
                {
                     value_node_t & error = errors.add_child_node(value_kind::Object);
                     error.add_child_node(value_kind::String, "message", error_msg);
                }
            }
            return true;
        }
    };
}
